package com.tengju.bff.infrastructure.export.convert;

import com.tengju.bff.interfaces.manage.crm.dealer.vo.ExportWechatDealerInfoVO;
import com.tengju.export.domain.record.Table;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: 李大仙
 * @date: 2021/12/14 4:32 下午
 */
public class ExportWechatDealerInfoVoConvert {

    public static Table convert(List<ExportWechatDealerInfoVO> list) {
        Table table = new Table();
        table.setHeader(buildHeader());
        table.setRecords(buildRecords(list));
        return table;
    }

    private static List<List<String>> buildRecords(List<ExportWechatDealerInfoVO> list) {
        //构造导出数据
        int index = 1;
        List<List<String>> dataList = new ArrayList<>();
        for (ExportWechatDealerInfoVO dealerInfoVO : list) {
            List<String> row = new ArrayList<>();

            row.add(String.valueOf(index));
            row.add(String.valueOf(dealerInfoVO.getIdCode()));
            row.add(dealerInfoVO.getUserName());
            row.add(dealerInfoVO.getStarLevel());

            row.add(dealerInfoVO.getWechatStatus());
            row.add(dealerInfoVO.getBlStar1());
            row.add(dealerInfoVO.getBlStar2());
            row.add(dealerInfoVO.getBlStar3());
            row.add(dealerInfoVO.getBlStar4());
            row.add(dealerInfoVO.getBlEc());
            row.add(dealerInfoVO.getBlSec());

            dataList.add(row);
            index++;
        }
        return dataList;
    }

    private static List<String> buildHeader() {
        List<String> headerList = new ArrayList<>();
        headerList.add("序号");
        headerList.add("成员id");
        headerList.add("成员姓名");
        headerList.add("当前等级");
        headerList.add("状态");
        headerList.add("所属1星服务商");
        headerList.add("所属2星服务商");
        headerList.add("所属3星服务商");
        headerList.add("所属4星服务商");
        headerList.add("所属EC");
        headerList.add("所属Sec");
        return headerList;
    }
}
